package main

import (
	"clean/usecase/io/pb"
	"context"
	"fmt"
	"google.golang.org/protobuf/encoding/protojson"
	"nhooyr.io/websocket"
)

func main() {
	c, _, err := websocket.Dial(context.Background(), "ws://127.0.0.1:8080", &websocket.DialOptions{})
	if err != nil {
		panic(err.Error())
	}

	in := &pb.Input{
		Msg: &pb.Input_InputHello{
			InputHello: &pb.InputHello{
				Name: "aa",
			},
		},
	}

	b, _ := protojson.Marshal(in)

	fmt.Println(string(b))

	c.Write(context.Background(), websocket.MessageText, b)

	_, bs, err := c.Read(context.Background())
	if err != nil {
		panic(err.Error())
	}

	fmt.Println(string(bs))

}
